package com.jt.service;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
 * Feign回调接口工厂对象,基于此对象创建Feign接口实现类对象.
 * 这个实现类对象,用于做容错处理?(有备无患,这里做熔断处理.)
 */
@Slf4j
@Component
public class ProviderFallbackFactory
        implements FallbackFactory<RemoteProviderService> {
    @Override
    public RemoteProviderService create(Throwable throwable) {
//        return new RemoteProviderService() {
//            @Override
//            public String echoMessage(String msg) {
//                //...报警...(发短信,email,日志.....)
//                return "服务暂时不可用，请稍后重试";
//            }
//        };
        return msg->{
            log.error("error:{}","sca-provider服务调用失败");
            return "服务暂时不可用，请稍后重试";
        };
    }
}
